<!--
 * @Description: file content
 * @Author: Zt2tzzt
 * @Date: 2021-09-18 09:55:26
 * @LastEditors: Zt2tzzt
 * @LastEditTime: 2021-09-18 10:03:13
 * @LastEditContent: 
-->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app"></div>

  <template id="my-app">
    你的问题：<input type="text" v-model="question">
  </template>

  <script src="https://unpkg.com/vue@next"></script>
  <script>
    const app = {
      template: '#my-app',
      data() {
        return {
          // 侦听 question 的变化时，去进行一些逻辑的处理( javaScript, 网络请求)
          question: 'Hello World',
          answer: ''
        }
      },
      watch: {
        // question 侦听的 data 中的属性名
        // newVal 变化后的值
        // oldVal 变化前的值
        question(newVal, oldVal) {
          console.log('新值', newVal, '旧值', oldVal)
          this.queryAnswer()
        }
      },
      computed: {
        
      },
      methods: {
        queryAnswer() {
          console.log(`你的问题${this.question}的答案是嘿嘿嘿嘿`)
        }
      }
    }
    Vue.createApp(app).mount('#app')
  </script>
</body>
</html>